home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Micro Mail / MicroMail.jar / MessageDetails.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-14  |  3.3 KB  |  94 lines

  1. import javax.microedition.lcdui.Command;
  2. import javax.microedition.lcdui.CommandListener;
  3. import javax.microedition.lcdui.Displayable;
  4. import javax.microedition.lcdui.Form;
  5.  
  6. public class MessageDetails extends Form implements CommandListener {
  7.    private MicroMail midlet;
  8.    private MessageList parent;
  9.    private int activeBoxId;
  10.    private int activeMsgId;
  11.    private Message message;
  12.    Command backCommand;
  13.    Command editCommand;
  14.    Command replyCommand;
  15.    Command deleteCommand;
  16.    Command markunreadCommand;
  17.  
  18.    public MessageDetails(MicroMail var1, MessageList var2, int var3, int var4) {
  19.       super(MicroMail.r.getText(25));
  20.       this.backCommand = new Command(MicroMail.r.getText(1), 2, 6);
  21.       this.editCommand = new Command(MicroMail.r.getText(5), 1, 1);
  22.       this.replyCommand = new Command(MicroMail.r.getText(6), 1, 2);
  23.       this.deleteCommand = new Command(MicroMail.r.getText(3), 1, 3);
  24.       this.markunreadCommand = new Command(MicroMail.r.getText(8), 1, 5);
  25.       this.midlet = var1;
  26.       this.parent = var2;
  27.       this.activeBoxId = var3;
  28.       this.activeMsgId = var4;
  29.       this.message = MicroCache.getMessage(this.activeBoxId, this.activeMsgId);
  30.       ((Displayable)this).setCommandListener(this);
  31.       ((Displayable)this).addCommand(this.backCommand);
  32.       if (this.activeBoxId == 2) {
  33.          ((Displayable)this).addCommand(this.editCommand);
  34.       }
  35.  
  36.       if (this.activeBoxId == 1) {
  37.          ((Displayable)this).addCommand(this.replyCommand);
  38.       }
  39.  
  40.       ((Displayable)this).addCommand(this.deleteCommand);
  41.       ((Displayable)this).addCommand(this.markunreadCommand);
  42.       this.displayMessage();
  43.       MicroCache.markRead(this.activeBoxId, this.message, this.activeMsgId, true);
  44.       this.parent.updateItem(this.activeMsgId, this.message.subject, true);
  45.    }
  46.  
  47.    public void commandAction(Command var1, Displayable var2) {
  48.       if (var1 == this.backCommand) {
  49.          MicroMail.display.setCurrent(this.parent);
  50.       } else if (var1 == this.editCommand) {
  51.          MessageForm var3 = new MessageForm(this.midlet, this.parent, this.message, this.activeMsgId);
  52.          MicroMail.display.setCurrent(var3);
  53.       } else if (var1 == this.replyCommand) {
  54.          String var5 = this.message.to;
  55.          if (this.message.replyTo != null && this.message.replyTo.length() > 0) {
  56.             this.message.to = this.message.replyTo;
  57.          } else {
  58.             this.message.to = this.message.from;
  59.          }
  60.  
  61.          this.message.from = var5;
  62.          this.message.body = "";
  63.          this.message.ID = -1;
  64.          MessageForm var4 = new MessageForm(this.midlet, this, this.message, -1);
  65.          MicroMail.display.setCurrent(var4);
  66.       } else if (var1 == this.deleteCommand) {
  67.          MicroCache.deleteMessage(this.activeBoxId, this.activeMsgId, this.message);
  68.          this.parent.deleteItem(this.activeMsgId);
  69.          MicroMail.display.setCurrent(this.parent);
  70.       } else if (var1 == this.markunreadCommand) {
  71.          MicroCache.markRead(this.activeBoxId, this.message, this.activeMsgId, false);
  72.          this.parent.updateItem(this.activeMsgId, this.message.subject, false);
  73.          MicroMail.display.setCurrent(this.parent);
  74.       }
  75.  
  76.       MicroMail.dispose(this);
  77.    }
  78.  
  79.    public void displayMessage() {
  80.       if (this.activeBoxId != 1 && this.activeBoxId != 4) {
  81.          ((Form)this).append(MicroMail.r.getText(26) + this.message.to + "\r\n");
  82.          ((Form)this).append(MicroMail.r.getText(29) + this.message.subject + "\r\n");
  83.          ((Form)this).append(MicroMail.r.getText(30) + this.message.body + "\r\n");
  84.       } else {
  85.          ((Form)this).append(MicroMail.r.getText(27) + this.message.from + "\r");
  86.          ((Form)this).append(MicroMail.r.getText(26) + this.message.to + "\r");
  87.          ((Form)this).append(MicroMail.r.getText(28) + this.message.date + "\r");
  88.          ((Form)this).append(MicroMail.r.getText(29) + this.message.subject + "\r");
  89.          ((Form)this).append(MicroMail.r.getText(30) + this.message.body + "\r");
  90.       }
  91.  
  92.    }
  93. }
  94.